import  {useState} from "react";

export default () => {
  
    let [num, setNum] = useState(0);
  
    let handler = () => {
      
        setNum(num +1);
      
        setTimeout(() => {
            console.log(num); // -> 0
        },2000)
      
        console.log(num); // -> 0
    }
    return<>
        <p>num: {num}</p>
        <button onClick={handler}>按钮</button>
    </>
}